# Example input file to test spider (based on the
# tensor_mechanics tutorial with Gmsh, Step 1, part 1: 2D
# simulation of uniaxial tension with linear elasticity)

# Status: needs to be converted from finite to small strain

[GlobalParams]
  displacements = 'disp_x disp_y disp_z'
  order = first
[]

[Mesh]
  file = cube.msh
  dim = 3
[]

# Use this if your mesh is 2D (dim = 2)
# [MeshModifiers]
#   [./extrude]
#     type = MeshExtruder
#     extrusion_vector = '0 0 1'
#     num_layers = 1
#     # Name for the node set of the back side
#     bottom_sideset = 'back'
#     # Name for the node set of the front side
#     top_sideset = 'front'
# [../]

[Variables]
  [./disp_x]
  [../]
  [./disp_y]
  [../]
  [./disp_z]
  [../]
[]

[Kernels]
  [./TensorMechanics]
    use_displaced_mesh = true
  [../]
[]

[Materials]
  [./elasticity_tensor]
    type = spider
    lambda = 1.2e7
    mu = 1.2e7
  [../]

  [./strain]
    type = ComputeFiniteStrain
  [../]

  [./stress]
    type = ComputeFiniteStrainElasticStress
  [../]
[]

[BCs]
  [./fix_x]
    type = PresetBC
    variable = disp_x
    boundary = left
    value = 0
  [../]
  [./fix_y]
    type = PresetBC
    variable = disp_y
    boundary = bottom
    value = 0
  [../]
  [./fix_z]
    type = PresetBC
    variable = disp_z
    boundary = back
    value = 0.0
  [../]
  [./pull]
    type = PresetBC
    variable = disp_z
    boundary = front
    value = 10e-6
  [../]
[]

[Preconditioning]
  [./SMP]
    type = SMP
    full = true
  [../]
[]

[Executioner]
  type = Steady

  solve_type = 'NEWTON'
  # # To check the Jacobian (together with solve_type = "NEWTON"):
  # # (from the mailing list: -ksp_view_mat)
  # petsc_options = '-snes_ksp_ew -ksp_view_mat'
  petsc_options = '-snes_ksp_ew'
  petsc_options_iname = '-pc_type -sub_pc_type -pc_asm_overlap -ksp_gmres_restart'
  petsc_options_value = 'asm lu 1 101'
[]

[AuxVariables]
  [./stress_xx]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./stress_xy]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./stress_xz]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./stress_yx]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./stress_yy]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./stress_yz]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./stress_zx]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./stress_zy]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./stress_zz]
    family = MONOMIAL
    order = CONSTANT
  [../]

  [./strain_xx]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./strain_xy]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./strain_xz]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./strain_yx]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./strain_yy]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./strain_yz]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./strain_zx]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./strain_zy]
    family = MONOMIAL
    order = CONSTANT
  [../]
  [./strain_zz]
    family = MONOMIAL
    order = CONSTANT
  [../]
[]

[AuxKernels]
  [./stress_xx]
    type = RankTwoAux
    variable = stress_xx
    rank_two_tensor = stress
    index_i = 0
    index_j = 0
  [../]
  [./stress_xy]
    type = RankTwoAux
    variable = stress_xy
    rank_two_tensor = stress
    index_i = 0
    index_j = 1
  [../]
  [./stress_xz]
    type = RankTwoAux
    variable = stress_xz
    rank_two_tensor = stress
    index_i = 0
    index_j = 2
  [../]
  [./stress_yx]
    type = RankTwoAux
    variable = stress_yx
    rank_two_tensor = stress
    index_i = 1
    index_j = 0
  [../]
  [./stress_yy]
    type = RankTwoAux
    variable = stress_yy
    rank_two_tensor = stress
    index_i = 1
    index_j = 1
  [../]
  [./stress_yz]
    type = RankTwoAux
    variable = stress_yz
    rank_two_tensor = stress
    index_i = 1
    index_j = 2
  [../]
  [./stress_zx]
    type = RankTwoAux
    variable = stress_zx
    rank_two_tensor = stress
    index_i = 2
    index_j = 0
  [../]
  [./stress_zy]
    type = RankTwoAux
    variable = stress_zy
    rank_two_tensor = stress
    index_i = 2
    index_j = 1
  [../]
  [./stress_zz]
    type = RankTwoAux
    variable = stress_zz
    rank_two_tensor = stress
    index_i = 2
    index_j = 2
  [../]

  [./strain_xx]
    type = RankTwoAux
    variable = strain_xx
    rank_two_tensor = total_strain
    index_i = 0
    index_j = 0
  [../]
  [./strain_xy]
    type = RankTwoAux
    variable = strain_xy
    rank_two_tensor = total_strain
    index_i = 0
    index_j = 1
  [../]
  [./strain_xz]
    type = RankTwoAux
    variable = strain_xz
    rank_two_tensor = total_strain
    index_i = 0
    index_j = 2
  [../]
  [./strain_yx]
    type = RankTwoAux
    variable = strain_yx
    rank_two_tensor = total_strain
    index_i = 1
    index_j = 0
  [../]
  [./strain_yy]
    type = RankTwoAux
    variable = strain_yy
    rank_two_tensor = total_strain
    index_i = 1
    index_j = 1
  [../]
  [./strain_yz]
    type = RankTwoAux
    variable = strain_yz
    rank_two_tensor = total_strain
    index_i = 1
    index_j = 2
  [../]
  [./strain_zx]
    type = RankTwoAux
    variable = strain_zx
    rank_two_tensor = total_strain
    index_i = 2
    index_j = 0
  [../]
  [./strain_zy]
    type = RankTwoAux
    variable = strain_zy
    rank_two_tensor = total_strain
    index_i = 2
    index_j = 1
  [../]
  [./strain_zz]
    type = RankTwoAux
    variable = strain_zz
    rank_two_tensor = total_strain
    index_i = 2
    index_j = 2
  [../]
[]

[Postprocessors]
  [./ave_stress_back_z]
    type = SideAverageValue
    variable = stress_zz
    boundary = back
  [../]
  [./ave_strain_front_z]
    type = SideAverageValue
    variable = strain_zz
    boundary = front
  [../]
[]

[Outputs]
  exodus = true
  print_perf_log = false
[]
